<TMPL_INCLUDE name=header.html>

<TABLE width="100%" height="350px">
<TR>
<TD width=50%>
<div id=group_list>
    <TMPL_INCLUDE name=Groups/GroupList.html>
</div>
</TD>
<TD>
    <TMPL_INCLUDE name=Campaigns/campaign_list.html>
</TD>
</TR>
</TABLE>
<hr>
<TMPL_INCLUDE name=Groups/new_group.html>

<div id=group_combine_results>
</div>

<TMPL_INCLUDE name=footer.html>

<script>

var groups_to_combine   = '';

function Load_EditGroup(group_id) {
    Modalbox.show("<TMPL_VAR name=APP_PATH>/cgi-bin/admin/groups/EditGroup?group_id=" + group_id, {title: 'change group', width: 500});
}
</script>

<script>
function EditGroup() 
{
    URL	= "<TMPL_VAR name=APP_PATH>/cgi-bin/admin/groups/EditGroup";
    PARAMS	= "action=edit&groupeditor__group_id=" + $('groupeditor__group_id').value + "&groupeditor__group_name=" + escape($('groupeditor__group_name').value);
    // alert(PARAMS);return;
    new Ajax.Updater (
        'group_list',
        URL,
        {
                method: 'GET',
                parameters: PARAMS,
        }
    );
}

function LoadCampaigns(group_id)
{
    URL	= "<TMPL_VAR name=APP_PATH_CGI>/admin/Groups.pl";
    PARAMS	= "action=load_campaigns&group_id=" + group_id;
    new Ajax.Updater ('campaign_list', URL, {parameters: PARAMS, onLoading:PrintStatus('campaign_list', 'Loading...'),});
}

function HideGroup(group_id)
{
    URL	= "<TMPL_VAR name=APP_PATH_CGI>/admin/Groups.pl";
    PARAMS	= "action=hide&group_id=" + group_id;
    new Ajax.Updater (
        'group_list', 
        URL, 
        {
            parameters: PARAMS, 
            onLoading:PrintStatus('header_status', 'Loading...'),
            onComplete: ClearStatus,
        });
}

// Could be integrated into a single function together with HideGroup (ex. toggle_active_group)
function ShowGroup(group_id)
{
    URL	= "<TMPL_VAR name=APP_PATH_CGI>/admin/Groups.pl";
    PARAMS	= "action=show&group_id=" + group_id;
    new Ajax.Updater (
        'group_list', 
        URL, 
        {
            parameters: PARAMS, 
            onLoading:PrintStatus('header_status', 'Loading...'),
            onComplete: ClearStatus,
        });
}

function RefreshGroups(active)
{
    active == 'undefined' ? active : 1;

    URL	= "<TMPL_VAR name=APP_PATH_CGI>/admin/Groups.pl";
    PARAMS	= "action=refresh&active=" + active;
    // prompt('', URL + "?" + PARAMS);
    new Ajax.Updater (
            'group_list', 
            URL, 
            {
                parameters: PARAMS, 
                onLoading:PrintStatus('header_status', 'Loading...'),
                onComplete: ClearStatus,
            });
}

function combine_group(group_id, combine_value)
{
    if (groups_to_combine)
        groups_to_combine   = groups_to_combine + ',' + group_id;
    else
        groups_to_combine   = group_id;

    $('group_combine_results').innerHTML  = "groups_to_combine = " + groups_to_combine;
    combine_id  = 'combine_' + group_id
    alert('comb_id_' + combine_id + ' = ' + $(combine_id).checked);
    return;
}
</script>